package com.frontalcode
{
	/**
	 * The FrontalError is used to report Frontal exceptions.
	 */
	public class FrontalError extends Error
	{
		// ActionScriptInterpreter errors.
		//
		static public var TYPE_ERROR						: String = "TypeError";
		static public var REFERENCE_ERROR					: String = "ReferenceError";
		static public var UNEXPECTED_TOKEN					: String = "UnexpectedToken";
		static public var UNIMPLEMENTED_LANGUAGE_ELEMENT	: String = "UnimplementedLanguageElement";
		static public var UNKNOWN_OPERATOR					: String = "UnknownOperator";
		static public var SYNTAX_ERROR						: String = "SyntaxError";
		
		public var code : String;
		
		/**
		 * Creates a new FrontalError instance.
		 */
		public function FrontalError ( message : String, code : String = null )
		{
			super ( message, 0 );
			
			this.code = code;
		}
		
		/*
		
			XXX Very annoyingly I can't seem to overide this function. I 
			followed the instructions for creating custom errors but to no
			avail.
		
		public override function toString ( ...args ) : String
		{
			var msg : String = super.toString ( );
			
			if ( code != null ) msg = code + ": " + msg;
			
			return msg;
		}
		*/
	}
}

